IF(WIN32)
	# Od : no optimisation; Ot: favor code speed over code size.
	if(DO_NOT_OPTIMIZE_WINDOWS_RELEASE)
		SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Od /Ot")
	endif(DO_NOT_OPTIMIZE_WINDOWS_RELEASE)
	ADD_DEFINITIONS(-D_CILK_)
ELSE(WIN32)
	# CGAL needs rounding math to compile well with GCC
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frounding-math")
ENDIF(WIN32)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/field-polygon/cmake/")
find_package(Knitro REQUIRED)
find_package(OpenCV 2 REQUIRED)

AUX_SOURCE_DIRECTORY(. SUB_SOURCES)
AUX_SOURCE_DIRECTORY(../common SUB_SOURCES)
SET(SOURCES ${SOURCES} ${SUB_SOURCES})

INCLUDE_DIRECTORIES(${CGAL_DIR}/include)
INCLUDE_DIRECTORIES($(OpenCV_DIR)/include)
INCLUDE_DIRECTORIES(${KNITRO_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${ICPP_COMPILER13}/mkl)

IF (WIN32)
   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/glut-win32/include)
   LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/glut-win32/lib)
   ADD_EXECUTABLE(field_polygon ${SOURCES})
ELSE (WIN32)
   LINK_DIRECTORIES(/usr/X11R6/lib)
   ADD_EXECUTABLE(field_polygon ${SOURCES})
ENDIF (WIN32)

ADD_DEPENDENCIES(field_polygon geex)

ADD_DEFINITIONS(-DNOMINMAX) 

IF (WIN32)
	TARGET_LINK_LIBRARIES(field_polygon geex opengl32 glu32 ${KNITRO_LIBRARY} ${OpenCV_LIBS} ${ICPP_COMPILER13})
	SET_TARGET_PROPERTIES(field_polygon PROPERTIES COMPILE_FLAGS "/openmp")
   	SET_TARGET_PROPERTIES(field_polygon PROPERTIES LINK_FLAGS "/LARGEADDRESSAWARE")
ELSE (WIN32)
   TARGET_LINK_LIBRARIES(field_polygon geex glut GL GLU CGAL gomp)
   SET_TARGET_PROPERTIES(field_polygon PROPERTIES COMPILE_FLAGS "-fopenmp")
ENDIF (WIN32)
